package com.imu.purse.modules.trade.dao;

import java.util.List;
import org.apache.ibatis.annotations.Select;
import com.imu.core.base.BaseMapper;
import com.imu.purse.modules.trade.entity.YmbWithdrawEntity;

/**
 * 易买宝充值详情表
 * @author sunhongwei
 * @email sunhongwei@jshijian.com
 * @date 2018-07-02 23:47:18
 * Copyright (c) 2017 武汉极时间科技有限公司 版权所有 
 * Jshijian aloha CO.,LTD. All Rights Reserved. 
 */
public interface YmbWithdrawMapper extends BaseMapper<YmbWithdrawEntity>
{
	/**
     * 分页查询
     * @return
     */
	@Select({
		"<script>",
		    "SELECT id,",
					"user_id, ",
					"bj_num, ",
					"money, ",
					"card_no, ",
					"phone, ",
					"order_state, ",
					"description, ",
					"create_time, ",
					"update_time",
		    "FROM imu_ymb_withdraw ",
		    "WHERE 1 = 1",
			"<when test = 'userId != null'>",
		    	"AND `user_id` = #{userId}",
		    "</when>",
		    "<when test = 'stime != null'>",
		    	"AND create_time &gt;= #{stime}",
		    "</when>",
			"<when test = 'etime != null'>",
		    	"AND create_time &lt;= #{etime}",
		    "</when>",
		    "LIMIT 1",
    	"</script>"
	})
    public YmbWithdrawEntity find(final YmbWithdrawEntity entity);	
	
	/**
     * 分页查询
     * @return
     */
	@Select({
		"<script>",
		    "SELECT id,",
					"user_id, ",
					"bj_num, ",
					"money, ",
					"card_no, ",
					"phone, ",
					"order_state, ",
					"description, ",
					"create_time, ",
					"update_time",
		    "FROM imu_ymb_withdraw ",
		    "WHERE 1 = 1",
			"<when test = 'userId != null'>",
		    	"AND `user_id` = #{userId}",
		    "</when>",
			"<when test = 'orderState != null'>",
		    	"AND `order_state` = #{orderState}",
		    "</when>",
			"<when test = 'description != null'>",
		    	"AND `description` = #{description}",
		    "</when>",
			"<when test = 'sts != null'>",
		    	"AND `create_time` = #{sts}",
		    "</when>",
			"<when test = 'ets != null'>",
		    	"AND `update_time` = #{ets}",
		    "</when>",
		    "ORDER BY create_time DESC",
    	"</script>"
	})
    public List<YmbWithdrawEntity> findByPage(final YmbWithdrawEntity entity);
}
